<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center modifyNickname_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub modifyNickname_fd0_0'>
					<view class='flex flex-wrap align-center modifyNickname_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2'>&#xe794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='modifyNickname_fd0_0_c1_c0'>修改昵称</text>
					</view>
					<view class='flex flex-wrap align-center justify-end modifyNickname_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="loading_css" v-if="isShow">
				<u-loading size="36" color="#F35D2A"></u-loading>
				<view>加载中</view>
			</view>
			<block v-else>
				<!---flex布局flex布局开始-->
				<view class="flex flex-direction align-stretch benben-flex-layout modifyNickname_flex_1">
					<view class='flex flex-wrap align-center modifyNickname_fd1_0'>
						<input class='modifyNickname_fd1_0_c0' type="text" :placeholder="`请输入新昵称`" confirm-type="done"
							:maxlength="14" placeholder-style="color:#999;font-size:32rpx;"
							@input="valueInspectFunc($event)" v-model="user_nickname" />
					</view>
					<view class='flex flex-wrap align-center modifyNickname_fd1_1'>
						<text class='modifyNickname_fd1_1_c0'>请设置2-14个字符，不包含@《/等无效字符哦</text>
					</view>
				</view>

				<!---flex布局flex布局结束-->
				<view
					class="flex flex-wrap align-center justify-center benben-position-layout flex modifyNickname_flex_2"
					@tap="editUserNiknameFunc()">
					<view class="save_btn">
						保存
					</view>
				</view>
			</block>

			<view :style="{height: '128rpx'}"></view>


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"user_nickname": "",
				"newUserInfo": {
					"userinfo": {
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": ""
					}
				},
				"editname": "editname",
				"isShow": true,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			this.user_nickname = options.user_nickname;
			this.isShow = false;
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			editUserNiknameFunc() {
				if (!validate(this.user_nickname, 'require')) {
					this.$message.info('请输入新昵称');
					return false;
				}
				if (!validate(this.user_nickname, 'length', '1,14')) {
					this.$message.info('昵称不得超过14个字符');
					// return false;
				}
				if (this.user_nickname.split('').length < 2) {
					this.$message.info('最少2个字符');
					return
				}
				uni.$emit('chengeName', this.user_nickname);
				uni.navigateBack();
			},

			// //修改用户信息
			// async editUserNiknameFunc() {
			// 	if (!validate(this.userInfo.user_nickname, 'require')) {
			// 		this.$message.info('请输入新昵称');
			// 		return false;
			// 	}
			// 	if (!validate(this.userInfo.user_nickname, 'length', '1,10')) {
			// 		this.$message.info('昵称不得超过十个字符');
			// 		// return false;
			// 	}
			// 	if (this.userInfo.user_nickname.split('').length < 2) {
			// 		this.$message.info('最少2个字符');
			// 		return
			// 	}
			// 	//请求方法
			// 	//数据验证

			// 	let datanewUserInfo = await this.$api.post(global.apiUrls.post5cb54af125f1c, {
			// 		user_nickname: this.userInfo.user_nickname
			// 	});

			// 	if (datanewUserInfo.data.code != 1) {
			// 		this.$message.info(datanewUserInfo.data.msg);
			// 		return
			// 	}
			// 	let infonewUserInfo = datanewUserInfo.data;
			// 	this.newUserInfo = infonewUserInfo.data
			// 	this.$message.info(datanewUserInfo.data.msg);
			// 	uni.$emit('chengeName', )
			// 	setTimeout(() => {
			// 		uni.navigateBack();
			// 	}, 800)
			// },
			//监听输入框输入事件
			valueInspectFunc(e) {
				var str = e.detail.value
				var newZz = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘'，。、]/gi;
				if (newZz.test(str)) {
					this.$nextTick(() => {
						this.userInfo.nickname = str.replace(newZz, '')

					})
					this.$message.info('昵称不能包含特殊字符');
					return;
				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	.save_btn {
		background: #F35D2A;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background-size: 100% auto;
		background: #fff;
	}

	.modifyNickname_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.modifyNickname_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 88rpx;
	}

	.modifyNickname_fd0_0_c0 {
		width: 120rpx;
	}

	.modifyNickname_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.modifyNickname_flex_1 {
		padding: 24rpx 30rpx 24rpx 30rpx;
	}

	.modifyNickname_fd1_1_c0 {
		color: #999999;
		font-size: 28rpx;
		font-weight: 400;
	}

	.modifyNickname_fd1_1 {
		margin: 32rpx 0rpx 0rpx 0rpx;
	}

	.modifyNickname_fd1_0_c0 {
		height: 50rpx;
		color: rgba(51, 51, 51, 1);
		font-size: 32rpx;
		font-weight: 500;
	}

	.modifyNickname_fd1_0 {
		background: #f8f8f8;
		background-size: 100% auto !important;
		border-radius: 16rpx;
		padding: 32rpx;
	}

	.modifyNickname_flex_2 {
		width: 750rpx;
		height: 128rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.modifyNickname_fd2_0 {
		background: var(--benbenbgColor2);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		width: 690rpx;
		line-height: 88rpx;
		font-size: 36rpx;
		color: #fff;
		height: 88rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}
</style>